/**
 * Created by zhangyj on 2017/6/6. 业务设置
 */
import send from '../http'
export default {
  /**
   * 查询账户工单
   * @param data {}
   * @returns {*}
   */
  queryAccountBusinessFlow () {
    let req = {
      data: {},
      action: 'config.business.queryAccountBusinessFlow'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 查询某个工单的所有工单步骤
   * @param data.flow_id
   * @returns [*]
   */
  queryBusinessFlowSteps (data) {
    let req = {
      data: data,
      action: 'config.business.queryBusinessFlowSteps'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 查询某个工单步骤的详细信息
   * @param data._id
   * @returns {*}
   */
  queryBusinessFlowStep (data) {
    let req = {
      data: data,
      action: 'config.business.queryBusinessFlowStep'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 添加流程字段
   * @param data
   * @param data.name  //字段名称
   * @param data.required  //是否必填
   * @param data.enable  //是否启用
   * @param data.type  //字段类型
   * @param data.default  //默认值
   * @param data.flow_id  //流程id
   * @returns {*}
   */
  addBusinessFlowField (data) {
    let req = {
      data: data,
      action: 'config.business.addBusinessFlowField'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 查询当前流程的所有字段
   * @param data
   * @param data.flow_id  //流程id
   * @returns {*}
   */
  queryAllBusinessFlowFields (data) {
    let req = {
      data: data,
      action: 'config.business.queryAllBusinessFlowFields'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 添加流程
   * @param data
   * @param data.name  //步骤名称
   * @param data.ctime  //工单时限设置
   * @param data.ctype  //工单时限类型
   * @returns {*}
   */
  addBusinessFlow (data) {
    let req = {
      data: data,
      action: 'config.business.addBusinessFlow'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 根据id查看流程信息
   * @param data
   * @param data._id  //流程id
   * @returns {*}
   */
  getBusinessFolwById (data) {
    let req = {
      data: data,
      action: 'config.business.getBusinessFolwById'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 保存流程信息
   * @param data
   * @param data.name  //步骤名称
   * @param data.ctime  //工单时限设置
   * @param data.ctype  //工单时限类型
   * @param data.version  //版本
   * @param data.tips  //流程提示
   * @returns {*}
   */
  updateBusinessFlowInfo (data) {
    let req = {
      data: data,
      action: 'config.business.updateBusinessFlowInfo'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 停用流程
   * @param data
   * @param data._id  //流程id
   * @param data.status  //停用
   * @returns {*}
   */
  changeStatusBusinessFlow (data) {
    let req = {
      data: data,
      action: 'config.business.changeStatusBusinessFlow'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 添加业务步骤
   * @param data
   * @param data._id  //流程id
   * @param data.name  //步骤名称
   * @param data.ctime  //工单时限设置
   * @param data.ctype  //工单时限类型
   * @param data.ownernotifyUser  //
   * @param data.notifyUser  //提醒座席
   * @returns {*}
   */
  addBusinessFlowStep (data) {
    let req = {
      data: data,
      action: 'config.business.addBusinessFlowStep'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 添加业务步骤
   * @param data
   * @param data._id  //流程id
   * @returns {*}
   */
  addBusinessStartStepFlow (data) {
    let req = {
      data: data,
      action: 'config.business.addBusinessStartStepFlow'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 步骤界面配置生效
   * @param data
   * @param data._id  //流程id
   * @param data.stepFields  //字段
   * @param data.stepFields[].cols  //行
   * @param data.stepFields[].cols.fields  //列
   * @param data.stepFields[].cols.fields[].type  //字段类型
   * @param data.stepFields[].cols.fields[]._id  //字段id
   * @returns {*}
   */
  updateBusinessStepInfo (data) {
    let req = {
      data: data,
      action: 'config.business.updateBusinessStepInfo'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 保存步骤信息
   * @param data
   * @param data._id  //步骤id
   * @param data.name  //步骤名称
   * @param data.ctime  //工单时限设置
   * @param data.ctype  //工单时限类型
   * @param data.ownernotifyUser  //
   * @param data.notifyUser  //提醒座席
   * @param data.isBegin  //是否为起始步骤
   * @param data.flow_id  //流程id
   * @returns {*}
   */
  updateBusinessFlowStep (data) {
    let req = {
      data: data,
      action: 'config.business.updateBusinessFlowStep'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 查询当前步骤的动作
   * @param data
   * @param data._id  //步骤id
   * @returns {*}
   */
  queryBusinessStepAction (data) {
    let req = {
      data: data,
      action: 'config.business.queryBusinessStepAction'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 添加步骤动作
   * @param data
   * @param data._id  //步骤id
   * @param data.name  //动作名称
   * @param data.jumpTo  //执行动作后转入
   * @param data.actionRole  //动作角色
   * @returns {*}
   */
  addBusinessStepAction (data) {
    let req = {
      data: data,
      action: 'config.business.addBusinessStepAction'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 动作界面保存配置
   * @param data
   * @param data._id  //步骤id
   * @param data.actionId  //动作id
   * @param data.update  {}
   * @param data.update.name //动作名称
   * @param data.update.jumpTo //执行动作后转入
   * @param data.update.actionRole //动作角色 []
   * @param data.update.actionFields[].cols //行
   * @param data.update.actionFields[].cols[].fields //列
   * @param data.update.actionFields[].cols[].fields[].type //字段类型
   * @param data.update.actionFields[].cols[].fields[]._id //字段id
   * @returns {*}
   */
  udpateBusinessStepAction (data) {
    let req = {
      data: data,
      action: 'config.business.udpateBusinessStepAction'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 删除步骤动作
   * @param data
   * @param data._id  //步骤id
   * @param data.actionId  //动作id
   * @returns {*}
   */
  deleteBusinessStepAction (data) {
    let req = {
      data: data,
      action: 'config.business.deleteBusinessStepAction'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 查询流程的所有字段
   * @param data
   * @param data.query  //名称
   * @param data.flow_id  //流程id
   * @param data.limit
   * @param data.page
   * @returns {*}
   */
  queryBusinessFlowFields (data) {
    let req = {
      data: data,
      action: 'config.business.queryBusinessFlowFields'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 更新工单对接流出url
   * @param data
   * @param data.outflowInterface.url  //url
   * @param data._id  //工单步骤id
   * @returns {*}
   */
  updateBusinessStepAPI (data) {
    let req = {
      data: data,
      action: 'config.business.updateBusinessStepAPI'
    }
    return send.fetch(req, 'post')
  },
  /*
  * 提交配置工单
  * */
  submitBusinessFlowApply (data) {
    let req = {
      data: data,
      action: 'config.business.submitBusinessFlowApply'
    }
    return send.fetch(req, 'post')
  },
  submitConfigBusinessFlowApply (data) {
    let req = {
      data: data,
      action: 'config.business.submitConfigBusinessFlowApply'
    }
    return send.fetch(req, 'post')
  },
  queryConfigBusiness (data) {
    let req = {
      data: data,
      action: 'config.business.queryConfigBusiness'
    }
    return send.fetch(req, 'post')
  },
  removeCnofigBusiness (data) {
    let req = {
      data: data,
      action: 'config.business.removeCnofigBusiness'
    }
    return send.fetch(req, 'post')
  },
  updateBusinessStepFields (data) {
    let req = {
      data: data,
      action: 'config.business.updateBusinessStepFields'
    }
    return send.fetch(req, 'post')
  },
  copyBusinessStepAction (data) {
    let req = {
      data: data,
      action: 'config.business.copyBusinessStepAction'
    }
    return send.fetch(req, 'post')
  },
  addBusinessFlowFields (data) {
    let req = {
      data: data,
      action: 'config.business.addBusinessFlowFields'
    }
    return send.fetch(req, 'post')
  },
  saveBusinessDockingConfiguration (data) {
    let req = {
      data: data,
      action: 'config.business.saveBusinessDockingConfiguration'
    }
    return send.fetch(req, 'post')
  },
  addBusinessTrigger (data) {
    let req = {
      data: data,
      action: 'config.business.addBusinessTrigger'
    }
    return send.fetch(req, 'post')
  },
  queryBusinessTrigger (data) {
    let req = {
      data: data,
      action: 'config.business.queryBusinessTrigger'
    }
    return send.fetch(req, 'post')
  },
  updateBusinessTrigger (data) {
    let req = {
      data: data,
      action: 'config.business.updateBusinessTrigger'
    }
    return send.fetch(req, 'post')
  },
  controlBusinessTrigger (data) {
    let req = {
      data: data,
      action: 'config.business.controlBusinessTrigger'
    }
    return send.fetch(req, 'post')
  },
  queryAccountBusinessTrigger () {
    let req = {
      data: {},
      action: 'config.business.queryAccountBusinessTrigger'
    }
    return send.fetch(req, 'post')
  },
  copyBusinessFlow (data) {
    let req = {
      data: data,
      action: 'config.business.cloneBusinessFlow'
    }
    return send.fetch(req, 'post')
  },
  saveAppraiseTemplate (data) {
    let req = {
      data: data,
      action: 'config.business.saveAppraiseTemplate'
    }
    return send.fetch(req, 'post')
  },
  getAppraiseTemplates (data) {
    let req = {
      data: data,
      action: 'config.business.getAppraiseTemplates'
    }
    return send.fetch(req, 'post')
  },
  queryBusinessInfoPushConfig (data) {
    let req = {
      data: data,
      action: 'config.business.queryBusinessInfoConfig'
    }
    return send.fetch(req, 'post')
  },
  updateBusinessInfoPushConfig (data) {
    let req = {
      data: data,
      action: 'config.business.updateBusinessInfoConfig'
    }
    return send.fetch(req, 'post')
  }
}
